package com.example.boot0601.controller;

import com.example.boot0601.entity.Pet;
import com.example.boot0601.mapper.PetMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PetController {
    @Autowired
    PetMapper mapper;
    @RequestMapping("/insert")
    public void insert(@RequestBody Pet pet){
        mapper.insert(pet);
    }
    @RequestMapping("/select")
    public List<Pet> select(){
        return mapper.select();
    }
    @RequestMapping("/delete")
    public void delete(int id){
        mapper.delete(id);
    }
    @RequestMapping("/selectById")
    public Pet selectById(int id){
       return mapper.selectById(id);
    }
    @RequestMapping("/update")
    public void update(@RequestBody Pet pet){
        mapper.update(pet);
    }

}
